Specifies the mutex type attribute that is used when a mutex is
created.
1 – C Binding
#include <pthread.h>
int
pthread_mutexattr_settype (
pthread_mutexattr_t *attr,
int type);
2 – Arguments
attr
Mutex attributes object whose mutex type attribute is to be
modified.
type
New value for the mutex type attribute. The type argument
specifies the type of mutex that will be created. Valid values
are:
PTHREAD_MUTEX_NORMAL
PTHREAD_MUTEX_DEFAULT (default)
PTHREAD_MUTEX_RECURSIVE
PTHREAD_MUTEX_ERRORCHECK
3 – Description
This routine sets the mutex type attribute that is used to
determine which type of mutex is created based on a subsequent
call to pthread_mutex_init().
4 – Return Values
If an error condition occurs, this routine returns an integer
value indicating the type of error. Possible return values are as
follows:
Return Description
0 Successful completion.
[EINVAL] The value specified by attr or type is not a valid
mutex attributes type.
[ESRCH] The value specified by attr does not refer to an
existing mutex attributes object.
5 – Associated Routines
pthread_mutexattr_init()
pthread_mutexattr_gettype()
pthread_mutex_init()